Skip to content

build: upgrade Kotlin 2.1.21, KSP 2.1.21-2.0.2, Room 2.7.2#8

Merged
hawkff merged 1 commit into
mainfrom
maintenance/update-kotlin-room
Jun 15, 2026
Merged

build: upgrade Kotlin 2.1.21, KSP 2.1.21-2.0.2, Room 2.7.2#8
hawkff merged 1 commit into
mainfrom
maintenance/update-kotlin-room

Conversation

@hawkff

@hawkff hawkff commented Jun 15, 2026

Copy link
Copy Markdown
Owner

Summary

Coordinated Kotlin/KSP/Room lockstep upgrade — the work deferred from the build-stack
PR (#7), where these could not move because Room 2.6.1's generated DAO is incompatible
with KSP2.

Component Before After
Kotlin 2.0.21 2.1.21
KSP 2.0.21-1.0.27 2.1.21-2.0.2
Room 2.6.1 2.7.2

Why these move together

KSP 2.1.x defaults to KSP2. Room 2.6.1 under KSP2 generates a broken suspend DAO
(Continuation<List<…>> vs Continuation<? super List<…>> erasure clash). Room 2.7.2
fixes that codegen. So Kotlin, KSP, and Room must move in one step.

On the KSP version scheme (pre-empting a likely review note)

KSP versions are {kotlin-version}-{ksp-release}. 2.1.21-2.0.2 = KSP for Kotlin
2.1.21
, KSP release 2.0.2. The trailing 2.0.2 is KSP's own release number, not a
Kotlin version. Verified:

  • Official tag google/ksp@2.1.21-2.0.2, published 2025-06-09.
  • Artifact resolves on Maven Central (symbol-processing-api/2.1.21-2.0.2, HTTP 200).
  • The build succeeds (debug + release) with this exact pairing.

Roomigrant compatibility (verified, not assumed)

com.github.MatrixDev.Roomigrant:0.3.4 is an older third-party migration generator.
I verified empirically that it still works with Room 2.7.2 + KSP2: the build generates
migrations and compiles cleanly. No Roomigrant change was needed.

Database impact: none

Room 2.7.2 exports identical schema JSON — app/schemas/ is unchanged after the build.
DB stays at version 8; no migration or user-data impact.

Verification (AWS Linux builder)

  • ./gradlew app:assembleOssDebug — BUILD SUCCESSFUL.
  • ./gradlew app:assembleOssRelease — BUILD SUCCESSFUL (R8 minify, lintVital with
    warningsAsErrors=true, desugaring all pass; only pre-existing deprecation warnings).
  • git status app/schemas — clean (no schema drift).

Scope

  • 3 files: build.gradle.kts (KSP), buildSrc/build.gradle.kts (Kotlin), app/build.gradle.kts (Room).
  • No source changes, no other app dependencies (OkHttp/AndroidX deferred to separate PRs).

Runtime testing note

Build-verified only; no emulator runtime test (account EC2 vCPU quota blocks bare-metal/
KVM emulator hosts — quota increase pending). Room schema is unchanged and the upgrade is
codegen-level, so runtime risk is low. Batched runtime QA planned once emulator capacity exists.

Coordinated lockstep upgrade (deferred from the build-stack PR, where these
could not move because Room 2.6.1's generated DAO is incompatible with KSP2):

- Kotlin 2.0.21 -> 2.1.21
- KSP 2.0.21-1.0.27 -> 2.1.21-2.0.2 (KSP2; matched to Kotlin)
- Room 2.6.1 -> 2.7.2 (fixes the KSP2 suspend-DAO Continuation codegen)

Roomigrant 0.3.4 remains compatible; generated migrations still build.
Room exports identical schema JSON (app/schemas unchanged), so there is no
database version change or migration impact (DB stays at version 8).
@coderabbitai

coderabbitai Bot commented Jun 15, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Summary by CodeRabbit

Chores

  • Updated core database library dependencies to latest stable versions, incorporating recent improvements in database performance and reliability
  • Upgraded Kotlin compiler plugin and build system tooling to latest compatible versions, ensuring enhanced build compatibility and improved development tool alignment
  • All infrastructure updates maintain full backward compatibility with existing application functionality

Walkthrough

Three Gradle build files receive version-only updates: the Kotlin Gradle plugin is bumped from 2.0.21 to 2.1.21, the KSP plugin from 2.0.21-1.0.27 to 2.1.21-2.0.2, and the three Android Room dependencies (room-runtime, room-compiler, room-ktx) from 2.6.1 to 2.7.2.

Changes

Kotlin, KSP, and Room dependency upgrades

Layer / File(s) Summary
Kotlin and KSP plugin version bumps
buildSrc/build.gradle.kts, build.gradle.kts
Kotlin Gradle plugin bumped from 2.0.21 to 2.1.21; KSP plugin bumped from 2.0.21-1.0.27 to 2.1.21-2.0.2.
Room library version bump
app/build.gradle.kts
room-runtime, room-compiler (ksp), and room-ktx all upgraded from 2.6.1 to 2.7.2.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐇 Hop, hop, the versions leap,
From old to new while bunnies sleep,
Room grows tall to 2.7.2,
And KSP gets a fresher view,
Kotlin jumps to 2.1 with glee—
All bumped in perfect harmony!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title directly and accurately summarizes the main changes: upgrading Kotlin, KSP, and Room to specific versions.
Description check ✅ Passed The description is comprehensive and directly related to the changeset, explaining the technical reasons for the coordinated upgrade, verification steps, and impacts.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Comment @coderabbitai help to get the list of available commands and usage tips.

@hawkff hawkff marked this pull request as ready for review June 15, 2026 18:01
@hawkff

hawkff commented Jun 15, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai full review

Please focus on the Kotlin/KSP/Room lockstep correctness and Room schema/migration safety.

Two notes pre-empting common findings:

  1. KSP version scheme: 2.1.21-2.0.2 is the OFFICIAL KSP release FOR Kotlin 2.1.21 (format is {kotlin-version}-{ksp-release}; the trailing 2.0.2 is KSP's own release number, NOT a Kotlin version). Verified: google/ksp tag 2.1.21-2.0.2 published 2025-06-09, artifact resolves on Maven Central, and both debug+release builds succeed with this exact pairing.
  2. Roomigrant 0.3.4 + Room 2.7.2: verified empirically — migrations generate and the build compiles. app/schemas is unchanged (no DB version change, DB stays at 8).

@coderabbitai

coderabbitai Bot commented Jun 15, 2026

Copy link
Copy Markdown

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Fetch the PR diff
gh pr view 8 --repo hawkff/NekoBoxForAndroid --json title,body,files,additions,deletions
echo "---FILES---"
gh pr diff 8 --repo hawkff/NekoBoxForAndroid

Length of output: 4526


🏁 Script executed:

#!/bin/bash
echo "=== app/build.gradle.kts ==="
cat app/build.gradle.kts

echo "=== build.gradle.kts ==="
cat build.gradle.kts

echo "=== buildSrc/build.gradle.kts ==="
cat buildSrc/build.gradle.kts

echo "=== app/schemas/ listing ==="
ls -la app/schemas/ 2>/dev/null || echo "No schemas dir"
ls -la app/schemas/io.nekohasekai.sagernet.database.SagerDatabase/ 2>/dev/null || true

echo "=== Any other Room/Kotlin/KSP references in gradle files ==="
rg -n "room|kotlin|ksp" --type=kotlin --iglob "*.kts" -i | grep -v "Binary" | head -80

echo "=== Check for any version catalog or versions.gradle ==="
fd "versions" --extension=toml --extension=gradle --extension=kts | head -20
cat gradle/libs.versions.toml 2>/dev/null || echo "No libs.versions.toml"

echo "=== Roomigrant references ==="
rg -rn "Roomigrant" --type=kotlin .
rg -rn "Roomigrant" . --glob="*.kts"

Length of output: 7161



@hawkff: Thorough review complete. Here is my full analysis focused on Kotlin/KSP/Room lockstep correctness and Room schema/migration safety.


Lockstep Correctness ✅

Check Result
KSP plugin prefix 2.1.21 matches kotlin-gradle-plugin:2.1.21
KSP version format 2.1.21-2.0.2 is the official Google release for Kotlin 2.1.21 ✅ (per user verification + tag published 2025-06-09)
All three Room artifacts at identical version 2.7.2 (room-runtime, room-compiler, room-ktx) ✅ — no internal version skew
Root build.gradle.kts, buildSrc/build.gradle.kts, and app/build.gradle.kts are the only files with KSP/Kotlin/Room version strings — no other gradle file references these
Roomigrant 0.3.4 (both RoomigrantLib and RoomigrantCompiler) left unchanged

The KSP2 default in 2.1.x + Room 2.7.2's switch to Kotlin codegen is the correct mechanism for resolving the Continuation<List<…>> vs Continuation<? super List<…>> erasure clash. The three components must move together and they do here.


Room Schema / Migration Safety ✅

  • app/schemas/io.nekohasekai.sagernet.database.SagerDatabase/ contains exactly 1.json through 8.json — no 9.json file was generated.
  • app/schemas/io.nekohasekai.sagernet.database.preference.PublicDatabase/ and moe.matsuri.nb4a.TempDatabase/ are also present and undisturbed.
  • room.schemaLocation and room.incremental = true KSP args are preserved in app/build.gradle.kts.
  • DB version remains at 8. No migration is added, none is needed.

Non-Blocking Observation (pre-existing, not introduced by this PR)

The project uses inline version strings for Room's three artifacts rather than a version catalog (libs.versions.toml). This means a future bump that touches only one of room-runtime/room-compiler/room-ktx could silently create an internal version skew (which would break at KSP annotation processing time). Worth consolidating into a version catalog or a val roomVersion = "..." constant in a future housekeeping PR.


Summary

The upgrade is minimal (5 additions, 5 deletions across 3 files), internally consistent, and correctly scoped. Lockstep invariant is maintained. Room schema is clean. No concerns with the changes as written.

[approve]

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
build.gradle.kts (1)

6-7: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Replace deprecated buildDir access in clean task.

Line 7 uses a deprecated API (rootProject.buildDir), which is already warning in CI. Switch to the layout API to avoid future Gradle breakage.

Proposed fix
 tasks.register<Delete>("clean") {
-    delete(rootProject.buildDir)
+    delete(rootProject.layout.buildDirectory)
 }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@build.gradle.kts` around lines 6 - 7, The clean task uses the deprecated
buildDir property which will cause breakage in future Gradle versions. In the
tasks.register<Delete>("clean") block, replace the rootProject.buildDir
reference with the layout API by using
rootProject.layout.buildDirectory.asFile.get() to get the build directory path
in a non-deprecated way.

Source: Pipeline failures

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@build.gradle.kts`:
- Around line 6-7: The clean task uses the deprecated buildDir property which
will cause breakage in future Gradle versions. In the
tasks.register<Delete>("clean") block, replace the rootProject.buildDir
reference with the layout API by using
rootProject.layout.buildDirectory.asFile.get() to get the build directory path
in a non-deprecated way.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 7d0b6582-85b0-4517-9310-df5920fb75e5

📥 Commits

Reviewing files that changed from the base of the PR and between a9517d7 and 990206f.

📒 Files selected for processing (3)
  • app/build.gradle.kts
  • build.gradle.kts
  • buildSrc/build.gradle.kts

@hawkff hawkff merged commit 9dadd24 into main Jun 15, 2026
2 of 3 checks passed
@hawkff hawkff deleted the maintenance/update-kotlin-room branch June 15, 2026 18:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant